<!--
 * @Author: your name
 * @Date: 2019-11-19 10:18:48
 * @LastEditTime: 2019-11-19 10:25:36
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \YouYouFo\you-you-go\src\views\news\NewsDetail.vue
 -->
<template>
  <div>
    <!-- 头部 -->
    <h2 class="news_hd">{{this.newsDetail.title}}</h2>
    <p class="margin-style">
      <span>发表时间:{{this.newsDetail.add_time}}</span>
      <span>点击:{{this.newsDetail.click}}</span>
    </p>
    <!-- 内容区域 -->
    <div v-html="this.newsDetail.content" class="continer"></div>    
    <!-- 评论区域 -->
    <yoviComment  
      :viId="id"
      :getCommentFun="getcomments"
      :postCommentFun="postcomment"
      :pageIndex="pageindex"></yoviComment>
   
  </div>
  <!-- :postCommentFun="postcomment" -->
</template>
           
<script>
import { getNewsDetail, getcomments ,postcomment} from '@/api/index'
import yoviComment from '@/common/YoviComment'
import { log } from 'util'
export default {
  data() {
    return {
      id: this.$route.params.id-0,
      newsDetail: [],
      pageindex: 1,
      getcomments,
      postcomment
    }
  },
  methods: {
    // 获取新闻资讯详情页面
    async getNewsDetail() {
      const { data: res } = await getNewsDetail(this.id)
      this.newsDetail = res.message[0]
      // console.log(res, 3434)
      // console.log(res.message[0], 5656)
    },
    
  },
  created() {
    this.getNewsDetail()
    // this.getcomments()
    console.log(this.id);
    
  },
  components: {
    yoviComment
  },
}
</script>
<style scoped>
.news_hd {
  margin: 10px;
  color: #65aae2;
  text-align: center;
}
.margin-style {
  padding: 10px;
  display: flex;
  color: #65aae2;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
}
.continer {
  margin-left: 10px;
}
.news_talk {
  padding: 10px;
  border-bottom: 1px solid #ccc;
}
.info {
  width: 100%;
}
.foot {
  height: 60px;
  width: 30px;
}
.list-item {
  background-color: #cccccc;
}
.list-item span,
.list-user{
  display: inline-block;
  height: 30px;
  line-height: 30px;
  margin:0 10px;
  letter-spacing: 1px
}
</style>